package com.example.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class ActivityB extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_b);

        TextView contentTv = findViewById(R.id.textView);


//        Intent intent = getIntent();
//        String name = intent.getStringExtra("name");
//        int age = intent.getIntExtra("age", 0);

        Bundle extras = getIntent().getExtras();
        String name = extras.getString("name");
        int age = extras.getInt("age");

        contentTv.setText("姓名："+ name + " 年龄：" + age);

    }

    public void back(View view) {
        Intent intent = new Intent();
        intent.putExtra("result","我是第二个页面返回的数据");
        setResult(RESULT_OK,intent);
        finish();
    }
}